package com.林子祺.CAT旅游系统.view;

import com.林子祺.CAT旅游系统.controller.login.MenuLogin;
import com.林子祺.CAT旅游系统.entity.login.LoginStatus;
import com.林子祺.CAT旅游系统.entity.place.CurrentPlaceData;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Recommend {

    public static void show() throws AWTException {

        JFrame jf = new JFrame("欢迎使用CAT旅游系统");
        jf.setSize(450, 450);
        jf.setLocationRelativeTo(null);
        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        JPanel panel = new JPanel(null);

        JLabel label01 = new JLabel();
        label01.setText("今日推荐");
        label01.setLocation(0,0);
        label01.setSize(200,50);
        label01.setFont(new Font(null, Font.PLAIN, 20));
        panel.add(label01);

        JLabel label02 = new JLabel();
        label02.setText(CurrentPlaceData.name);
        label02.setLocation(0,50);
        label02.setSize(400,100);
        label02.setFont(new Font(null, Font.PLAIN, 30));
        panel.add(label02);

        JLabel label03 = new JLabel();
        label03.setText(CurrentPlaceData.provience);
        label03.setLocation(0,150);
        label03.setSize(400,50);
        label03.setFont(new Font(null, Font.PLAIN, 20));
        panel.add(label03);

        JLabel label04 = new JLabel();
        label04.setText(CurrentPlaceData.city);
        label04.setLocation(0,200);
        label04.setSize(400,50);
        label04.setFont(new Font(null, Font.PLAIN, 20));
        panel.add(label04);

        JLabel label05 = new JLabel();
        label05.setText(CurrentPlaceData.address);
        label05.setLocation(0,250);
        label05.setSize(400,100);
        label05.setFont(new Font(null, Font.PLAIN, 20));
        panel.add(label05);

        final JButton btn5 = new JButton("返回");
        btn5.setLocation(0,350);
        btn5.setSize(100,30);
        btn5.setFont(new Font(null, Font.PLAIN, 17));
        panel.add(btn5);

        btn5.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // 获取到的事件源就是按钮本身
                // JButton btn = (JButton) e.getSource();
                try {
                    Menu.menu();
                    jf.dispose();
                } catch (Exception exception) {
                    exception.printStackTrace();
                }
            }
        });

        jf.setContentPane(panel);
        jf.setVisible(true);
    }

}
